package 力扣日常刷题.木22二月.第06天212;

import java.util.Arrays;

/**
 * @author 帅小伙
 * @date 2022/2/12
 * @description
 */
public class Demo46贪心最大数 {

    public String largestNumber(int[] nums) {
        String[] strs = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            strs[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(strs,(a,b)->(b+a).compareTo(a+b));
        StringBuffer sb = new StringBuffer();
        for (String str : strs) {
            sb.append(str);
        }
        return  sb.toString().charAt(0)== '0' ? "0" : sb.toString();

    }

}
